package com.mall.admin.service;

import com.mall.commons.utils.R;
import com.mall.domain.SmsHomeRecommendSubject;
import com.mall.interface1.api.SmsHomeRecommendSubjectServiceApi;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
public class SmsHomeRecommendSubjectService {


    @DubboReference
    SmsHomeRecommendSubjectServiceApi smsHomeRecommendSubjectServiceApi;

    public R findByPage(String brandName, Integer pageNum, Integer pageSize, Integer recommendStatus) {
        return R.success(smsHomeRecommendSubjectServiceApi.findByPage(brandName, pageNum, pageSize, recommendStatus));

    }

    public R updateRecommendStatus(List<Long> ids, Integer recommendStatus) {
        for (Long id : ids) {
            smsHomeRecommendSubjectServiceApi.updateRecommendStatus(id, recommendStatus);
        }


        return R.success("修改成功");
    }

    public R addCreate(List<SmsHomeRecommendSubject> homeBrandList) {
        for (SmsHomeRecommendSubject smsHomeRecommendSubject : homeBrandList) {
            smsHomeRecommendSubjectServiceApi.addCreate(smsHomeRecommendSubject);
        }
        return R.success("添加成功");
    }

    public R delete(List<Long> ids) {
        for (Long id : ids) {
            smsHomeRecommendSubjectServiceApi.delete(id);
        }
        return R.success("删除成功");
    }

    public R updateSort(Long id, Integer sort) {
        smsHomeRecommendSubjectServiceApi.updateSort(id, sort);
        return R.success("修改成功");
    }
}
